<!DOCTYPE html>
<html lang="{{page_locale}}"
    class="{{ gcb_html_element_class }}">
  <head>
    <base href="{{ gcb_course_base }}" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    {% block title %}
    {% endblock %}

    <!-- The following translated strings are used in activity-generic.js and should be
    declared before that file is imported. -->
    <script>
      // inline translations
      var trans = {};

      {# I18N: Text on the button for checking an answer. #}
      trans.CHECK_ANSWER_TEXT =
          "{{ gettext(' Check Answer ')|replace('\"', '\\\"') }}";

      {# I18N: Text on the button for checking a set of answers. #}
      trans.CHECK_ANSWERS_TEXT =
          "{{ gettext( ' Check Answers ')|replace('\"', '\\\"') }}";

      {# I18N: Text on the button for showing the answer to a question. #}
      trans.SHOW_ANSWER_TEXT =
          "{{ gettext(' Skip and Show Answer ')|replace('\"', '\\\"') }}";

      {# I18N: Text on the button for saving answers to a question. #}
      trans.SAVE_ANSWERS_TEXT =
          "{{ gettext(' Save Answers ')|replace('\"', '\\\"') }}";

      {# I18N: Text on the button for saving a draft answer. #}
      trans.SAVE_DRAFT_TEXT =
          "{{ gettext(' Save Draft ')|replace('\"', '\\\"') }}";

      {# I18N: Text on the button for submitting answers. #}
      trans.SUBMIT_ANSWERS_TEXT =
          "{{ gettext(' Submit Answers ')|replace('\"', '\\\"') }}";

      {# I18N: Text on the button for submitting a peer-reviewed assignment. #}
      trans.SUBMIT_ASSIGNMENT_TEXT =
          "{{ gettext(' Submit Assignment ')|replace('\"', '\\\"') }}";

      {# I18N: Text on the button for submitting a peer review. #}
      trans.SUBMIT_REVIEW_TEXT =
          "{{ gettext(' Submit Review ')|replace('\"', '\\\"') }}";

      {# I18N: Text to prompt the student to select a multiple-choice answer. #}
      trans.SELECT_ANSWER_PROMPT =
          "{{ gettext(' Please click one of the buttons for your answer. ')|replace('\"', '\\\"') }}";

      {# I18N: Text appearing after the student has answered all questions correctly. #}
      trans.ALL_CORRECT_TEXT =
          "{{ gettext(' All your answers are correct! ')|replace('\"', '\\\"') }}";

      {# I18N: Text appearing after the student has answered all questions correctly. #}
      trans.NUM_CORRECT_TEXT =
          "{{ gettext(' Number of questions you answered correctly ')|replace('\"', '\\\"') }}";

      {# I18N: Text appearing after the student has submitted an assessment. #}
      trans.YOUR_SCORE_TEXT =
          "{{ gettext(' You received a score on this assessment of ')|replace('\"', '\\\"') }}";

      {# I18N: Text appearing after the student has checked his/her answers to an assessment. #}
      trans.LESSONS_TO_REVIEW_TEXT =
          "{{ gettext(' Here are lessons you could review to improve your score ')|replace('\"', '\\\"') }}";

      {# I18N: Text appearing after the student has checked his/her answers to an assessment. #}
      trans.PERFECT_SCORE_SAVE_TEXT =
          "{{ gettext(' Congratulations! Press the \\\'Submit Answers\\\' button to submit your grade. ')|replace('\"', '\\\"') }}";

      {# I18N: Text appearing after the student has checked his/her answers to an assessment. #}
      trans.GENERIC_SAVE_TEXT =
          "{{ gettext(' Press the \\\'Submit Answers\\\' button below to save your scores. You can also edit your answers above before clicking \\\'Submit Answers\\\'. ')|replace('\"', '\\\"') }}";

      {# I18N: Text appearing in a confirmation dialog after the student has tried to submit an assignment. #}
      trans.SUBMIT_ASSIGNMENT_CONFIRMATION =
          "{{ gettext(' Are you sure you want to submit this assignment? ') }}";

      {# I18N: Text appearing in a confirmation dialog after the student has tried to submit a review. #}
      trans.SUBMIT_REVIEW_CONFIRMATION =
          "{{ gettext(' Are you sure you want to submit this review? ') }}";

      {# I18N: Text appearing in a confirmation dialog after 'Are you sure you want to submit this assignment/review?' #}
      trans.CONFIRMATION_EXPLANATION =
          "{{ gettext(' You cannot edit or delete it after you have done so. ') }}";
    </script>

    {% block assets %}
    {% endblock %}

    {% for url in extra_global_css_urls %}
      <link rel="stylesheet" href="{{url}}" type="text/css">
    {% endfor %}

    {% for url in extra_global_js_urls %}
      <script src="{{url}}" type="text/javascript"></script>
    {% endfor %}

    <script>
      var eventXsrfToken = '{{ event_xsrf_token }}';
      {% if record_tag_events %}
        var gcbCanPostTagEvents = true;
      {% endif %}
      {% if record_page_events %}
        var gcbCanPostPageEvents = true;
      {% endif %}
      {% if record_events %}
        var gcbCanPostEvents = true;
      {% endif %}

      {% if transient_student %}
        var transientStudent = true;
      {% else %}
        var transientStudent = false;
      {% endif %}
    </script>

    {% if course_info.base.show_gplus_button %}
      <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
    {% endif %}

    <script>
      function gcb_edit_hook_point(key) {
        window.location=('dashboard?action=edit_html_hook&key=' +
            encodeURIComponent(key));
      }
      $(function() {
        function parseJson(s) {
          var xssiPrefix = ")]}'";
          return JSON.parse(s.replace(xssiPrefix, ''));
        }

        $("#locale-select").change(function() {
          var localeSelect = $("#locale-select");
          var request = JSON.stringify({
            xsrf_token: localeSelect.data("xsrf-token"),
            payload: {
              selected: localeSelect.val()
            }
          });
          $.ajax({
            url: "rest/locale",
            type: "POST",
            data: {request: request},
            dataType: "text",
            success: function(data) {
              data = parseJson(data);
              if (data.status == 200) {
                window.location.reload();
              }
            }
          });
        });
      });
    </script>

    {% import 'ga.html' as ga %}
    {{ ga.render_google_analytics_script(
           course_info.course.google_analytics_id) }}

    {{ html_hooks.insert('base.before_head_tag_ends') | safe}}
  </head>

  <body data-gcb-page-locale="{{ page_locale }}">

    {{ html_hooks.insert('base.after_body_tag_begins') }}

    <script>
      // Course-Builder specific setup for Google Tag Manager.  Iff
      // Tag Managers is enabled, the values in the dataLayer list of
      // dicts is made available to Tag Manager macros.
      dataLayer = [{
        'course_title': '{{ course_info.course.title }}',
        'event': 'default',  // Explicit value meaning not-really-set.
        }];

      function gcbSetPageInfo(dict) {
        dataLayer.push(dict);
      }

      // Invoke page-specific block so that any calls to gcbReportPageInfo()
      // are made before we hit the Tag Manager call, below.
      {% block gcb_page_info %}
      {% endblock %}
    </script>

    {% if course_info.course.google_tag_manager_id %}
        <!-- Google Tag Manager.  This boilerplate code is as generated by the
             Tag Manager site, except that the ID is templated. -->
        <noscript><iframe src="//www.googletagmanager.com/ns.html?id={{ course_info.course.google_tag_manager_id }}"
        height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
        <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
        new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
        j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
        '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
        })(window,document,'script','dataLayer','{{ course_info.course.google_tag_manager_id }}');</script>
        <!-- End Google Tag Manager -->
    {% endif %}

    <!-- ButterBar -->
    <div class="gcb-butterbar-container">
      <div id="gcb-butterbar-top" class="gcb-butterbar" style="margin-top:50px" aria-live="polite">
        <p id="gcb-butterbar-message"></p>
        <a id="gcb-butterbar-close">X</a>
      </div>
    </div>

    <!-- logo bar -->
    <div id="gcb-header" role="banner">
      <div class="gcb-aux clearfix">
        <p class="gcb-course-image">
          <a href="./">
            <img src="{{course_info.institution.logo.url}}"
                 alt="{{course_info.institution.logo.alt_text}}">
          </a>
        </p>
        <p class="gcb-title-header">
          <a href="./">{{course_info.base.nav_header}}</a>
        </p>
        {% if course_info.base.show_gplus_button %}
          <span class="plusone-button" id="plusone-3" style="height: 15px; width: 70px; display: inline-block; text-indent: 0px; margin: 0px; padding: 0px; background-color: transparent; border-style: none; float: none; line-height: normal; font-size: 1px; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial; ">
            <g:plusone size="medium"></g:plusone>
          </span>
        {% endif %}

        {% if logoutUrl %}
        <div class="gcb-pull-right" style="font-size: larger;">
          {{ email }}
          {% if transient_student and can_register %}
            {# I18N: Text shown in parentheses next to the student's email address at the top-right of all course pages, if the student is logged in but not registered for the course he/she is currently browsing. #}
            ({{ gettext('Not registered') }})
          {% endif %}
          &nbsp;|&nbsp;
          <a href="{{ logoutUrl }}" style="text-decoration: underline;">
            {# I18N: Navbar text. #}
            {{ gettext('Logout') }}
          </a>
        </div>
        {% elif loginUrl %}
        <div class="gcb-pull-right" style="font-size: larger;">
          {# I18N: Navbar text. #}
          <a href="{{ loginUrl }}">{{ gettext('Login') }}</a>
        </div>
        {% endif %}
      </div>
    </div>

    {% block navbar %}
    {% endblock %}

    <!-- top section -->
    <div class="is-wrapper">
      <div class="gcb-aux">
        {% block top_content %}{% endblock %}
        {{ html_hooks.insert('base.after_top_content_ends') }}

        <!-- main section -->
        {% block main_content %}{% endblock %}
        {{ html_hooks.insert('base.after_main_content_ends') }}
      </div>
    </div>

    <!-- footer section -->
    <div style="margin-top: 50px;" id="gcb-signature"></div>
    <div class="gcb-footer" id="gcb-footer">
      <div id="gcb-footer-local">
        <div class="gcb-aux">
        </div>
      </div>
      <div id="gcb-footer-global" role="contentinfo">
        <div class="gcb-aux">
          <ul>
            <li>
              <a href="{{course_info.institution.url}}" target="_blank">{{course_info.institution.name}}</a>
            </li>
            <li>
              <a href="{{course_info.base.privacy_terms_url}}" target="_blank">
                {# I18N: Link at the bottom of each page to the privacy and 'Terms and Conditions' pages. #}
                {{ gettext('Privacy & Terms') }}
              </a>
            </li>
            {% if available_locales %}
              <li>
                {# I18N: Text describing the locale selector. #}
                {{ gettext('Locale:') }}
                <select id="locale-select" data-xsrf-token="{{ locale_xsrf_token}}">
                  {% for locale in available_locales %}
                    <option value="{{ locale.value }}"
                      {% if locale.value == selected_locale %}selected{% endif %}>
                      {{ locale.name }}
                    </option>
                  {% endfor %}
                </select>
              </li>
            {% endif %}
          </ul>
        </div>
      </div>
    </div>
    {{ html_hooks.insert('base.before_body_tag_ends') }}

    {% if context %}
      <div class="gcb-jinja-context">
      {% for key, value in context() | dictsort %}
          <p>{{ key }}: {{ value | forceescape }}<p>
      {% endfor %}
      </div>
    {% endif %}
    {% if debug_info %}
<!-- gcb-debug-info-begin
{{ debug_info }}
gcb-debug-info-end //-->
{% endif %}
 </body>
</html>
